package com.sg.business.model.dataset.project;

import java.util.ArrayList;
import java.util.List;

import com.mobnut.db.model.DataSet;
import com.mobnut.db.model.PrimaryObject;
import com.sg.business.model.IModelConstants;
import com.sg.business.model.Work;
import com.sg.widgets.commons.dataset.MasterDetailDataSetFactory;

public class WBSAndDeliveryOfWork extends MasterDetailDataSetFactory {

	public WBSAndDeliveryOfWork() {
		super(IModelConstants.DB, IModelConstants.C_WORK);
	}

	@Override
	protected String getDetailCollectionKey() {
		return Work.F_PARENT_ID;
	}

	@Override
	public DataSet getDataSet() {
		List<PrimaryObject> dataItems = new ArrayList<PrimaryObject>();
		if (master != null) {
			List<PrimaryObject> workList = master.getRelationById(Work.F__ID,
					Work.F_PARENT_ID, Work.class);
			dataItems.addAll(workList);
//			List<PrimaryObject> deliverableList = master.getRelationById(
//					Work.F__ID, Deliverable.F_WORK_ID, Deliverable.class);
//			dataItems.addAll(deliverableList);
		}
		return new DataSet(dataItems);

	}

}
